#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int n;
int r[MAXN];
int c[MAXN];
int p[MAXN];
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    ios :: sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>r[i];
        p[i]=r[i];
    }
    sort(p+1,p+n+1);
    int ans=0;
    int tot=unique(p+1,p+n+1)-p-1;
    for(int i=1;i<=n;i++)
    {
        int pos=lower_bound(p+1,p+tot+1,r[i])-p;
        c[pos]++;
    }
    int lst=c[1];
    for(int i=2;i<=tot;i++)
    {
        ans+=min(lst,c[i]);
        if(lst<c[i])
        {
            lst=c[i];
        }
        else
        {
            lst=lst;
        }
    }
    cout<<n-ans<<"\n";
    return 0;
}